/**
 *  @file ctc_greatbel_scl_cli.h
 *
 *   @date 2011-11-25
 *
 *    @version v2.0
 *
 *    ---file comments----
 *    */

#ifndef _CTC_USW_SCL_CLI_H
#define _CTC_USW_SCL_CLI_H
#ifdef __cplusplus
extern "C" {
#endif
#include "sal.h"
#include "ctc_cli.h"
#include "ctc_xdata.h"

#define  CTC_USW_SCL_XDATA_MAX  255

#define cli_usw_scl_xdata ((ctc_xdata_field_t*)CTC_VTY_CLIENT(vty)->scl_xdata)
#define cli_usw_scl_xdata_num   (CTC_VTY_CLIENT(vty)->scl_xdata_num)
#define cli_usw_scl_xdata_set   (CTC_VTY_CLIENT(vty)->scl_xdata_set)


#define CTC_CLI_SCL_ADD_UDF_SET(p_field, arg) \
    index = CTC_CLI_GET_ARGC_INDEX("ip-protocol");\
    if (0xFF != index) \
    {\
        p_field->type = CTC_FIELD_KEY_IP_PROTOCOL;\
        CTC_CLI_GET_UINT8("ip-protocol", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT8("ip-protocol", p_field->mask, argv[index + 2]);\
        arg; \
    }\
    index = CTC_CLI_GET_ARGC_INDEX("udf");\
    if (0xFF != index) \
    {\
        p_field->type = CTC_FIELD_KEY_UDF;\
        index = CTC_CLI_GET_ARGC_INDEX("udf-id");\
        if (INDEX_VALID(index))\
        {\
            CTC_CLI_GET_UINT32("udf-id", udf_data.udf_id, argv[index + 1]);\
        } \
        index = CTC_CLI_GET_ARGC_INDEX("udf-data");\
        if (INDEX_VALID(index))\
        {\
            CTC_CLI_GET_STR_DATA(udf_data.udf, udf_mask.udf, 1);\
        }\
        p_field->ext_data = &udf_data;\
        p_field->ext_mask = &udf_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("udf-ad-id");\
    if (0xFF != index) \
    {\
        p_field->type = CTC_FIELD_KEY_UDF_AD_ID;\
        CTC_CLI_GET_UINT32("udf-ad-id", udf_data.udf_ad_id, argv[index + 1]);\
        index = CTC_CLI_GET_ARGC_INDEX("udf-data");\
        if (INDEX_VALID(index))\
        {\
            CTC_CLI_GET_STR_DATA(udf_data.udf, udf_mask.udf, 1);\
        }\
        p_field->ext_data = &udf_data;\
        p_field->ext_mask = &udf_mask;\
        arg;\
    }


/**< [TM] Append key: 1.Packet stag valid 2.Packet ctag valid 3.Udf */
#define CTC_CLI_SCL_KEY_FIELD_TYPE_SET(p_field, arg) \
do{\
    uint8 action_begin = CTC_CLI_GET_ARGC_INDEX("action-field");\
    index = CTC_CLI_GET_ARGC_INDEX("ether-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_ETHER_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l2-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L2_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("vlan-num");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_VLAN_NUM;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l3-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L3_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l4-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L4_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l4-user-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L4_USER_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mac-sa");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MAC_SA;\
        CTC_CLI_GET_MAC_ADDRESS("value", mac_sa, argv[index + 1]);\
        CTC_CLI_GET_MAC_ADDRESS("mask", macsa_mask, argv[index + 2]);\
        p_field->ext_data = (void*)mac_sa;\
        p_field->ext_mask = (void*)macsa_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mac-da");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MAC_DA;\
        CTC_CLI_GET_MAC_ADDRESS("value", mac_da, argv[index + 1]);\
        CTC_CLI_GET_MAC_ADDRESS("mask", macda_mask, argv[index + 2]);\
        p_field->ext_data = (void*)mac_da;\
        p_field->ext_mask = (void*)macda_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("packet-stag-valid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_PKT_STAG_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("packet-ctag-valid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_PKT_CTAG_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("pi-stag-valid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MAPPED_STAG_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("pi-svlan-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MAPPED_SVLAN_ID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("pi-ctag-valid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MAPPED_CTAG_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("pi-cvlan-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MAPPED_CVLAN_ID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("stag-valid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_STAG_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("svlan-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_SVLAN_ID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("stag-cos");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_STAG_COS;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("stag-cfi");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_STAG_CFI;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ctag-valid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_CTAG_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("cvlan-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_CVLAN_ID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ctag-cos");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_CTAG_COS;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ctag-cfi");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_CTAG_CFI;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-sa");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_SA;\
        CTC_CLI_GET_IPV4_ADDRESS("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_IPV4_ADDRESS("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-da");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_DA;\
        CTC_CLI_GET_IPV4_ADDRESS("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_IPV4_ADDRESS("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ipv6-sa");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IPV6_SA;\
        CTC_CLI_GET_IPV6_ADDRESS("value", ipv6_sa, argv[index + 1]);\
        ipv6_sa[0] = sal_htonl(ipv6_sa[0]);\
        ipv6_sa[1] = sal_htonl(ipv6_sa[1]);\
        ipv6_sa[2] = sal_htonl(ipv6_sa[2]);\
        ipv6_sa[3] = sal_htonl(ipv6_sa[3]);\
        p_field->ext_data = ipv6_sa;\
        CTC_CLI_GET_IPV6_ADDRESS("mask", ipv6_sa_mask, argv[index + 2]);\
        ipv6_sa_mask[0] = sal_htonl(ipv6_sa_mask[0]);\
        ipv6_sa_mask[1] = sal_htonl(ipv6_sa_mask[1]);\
        ipv6_sa_mask[2] = sal_htonl(ipv6_sa_mask[2]);\
        ipv6_sa_mask[3] = sal_htonl(ipv6_sa_mask[3]);\
        p_field->ext_mask = ipv6_sa_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ipv6-da");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IPV6_DA;\
        CTC_CLI_GET_IPV6_ADDRESS("value", ipv6_da, argv[index + 1]);\
        ipv6_da[0] = sal_htonl(ipv6_da[0]);\
        ipv6_da[1] = sal_htonl(ipv6_da[1]);\
        ipv6_da[2] = sal_htonl(ipv6_da[2]);\
        ipv6_da[3] = sal_htonl(ipv6_da[3]);\
        p_field->ext_data = ipv6_da;\
        CTC_CLI_GET_IPV6_ADDRESS("mask", ipv6_da_mask, argv[index + 2]);\
        ipv6_da_mask[0] = sal_htonl(ipv6_da_mask[0]);\
        ipv6_da_mask[1] = sal_htonl(ipv6_da_mask[1]);\
        ipv6_da_mask[2] = sal_htonl(ipv6_da_mask[2]);\
        ipv6_da_mask[3] = sal_htonl(ipv6_da_mask[3]);\
        p_field->ext_mask = ipv6_da_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-ecn");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_ECN;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-dscp");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_DSCP;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-frag");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_FRAG;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-hdr-error");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_HDR_ERROR;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-options");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_OPTIONS;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ip-pkt-len-range-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_PKT_LEN_RANGE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l4-dst-port-range");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L4_DST_PORT_RANGE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
        index = CTC_CLI_GET_ARGC_INDEX("l4-src-port-range");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L4_SRC_PORT_RANGE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("is-ip-pkt");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IS_IP_PKT;\
        CTC_CLI_GET_UINT8("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT8("mask", p_field->mask, argv[index + 2]);\
        break;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("vxlan-pkt");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_VXLAN_PKT;\
        CTC_CLI_GET_UINT8("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT8("mask", p_field->mask, argv[index + 2]);\
        break;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("flow-label");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IPV6_FLOW_LABEL;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l4-dst-port");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L4_DST_PORT;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("l4-src-port");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_L4_SRC_PORT;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("tcp-ecn");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_TCP_ECN;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("tcp-flags");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_TCP_FLAGS;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ttl");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_TTL;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("gre-key");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_GRE_KEY;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("nvgre-key");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_NVGRE_KEY;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("vn-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_VN_ID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("icmp-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_ICMP_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("icmp-code");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_ICMP_CODE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("igmp-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_IGMP_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("global-port");\
    if (index < action_begin) \
    {\
        port_info.type = CTC_FIELD_PORT_TYPE_GPORT;\
        CTC_CLI_GET_UINT32("value", port_info.gport, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", port_info_mask.gport, argv[index + 2]);\
        p_field->type = CTC_FIELD_KEY_PORT;\
        p_field->ext_data = &port_info;\
        p_field->ext_mask = &port_info_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("logic-port");\
    if (index < action_begin) \
    {\
        port_info.type = CTC_FIELD_PORT_TYPE_LOGIC_PORT;\
        CTC_CLI_GET_UINT16("value", port_info.logic_port, argv[index + 1]);\
        CTC_CLI_GET_UINT16("mask", port_info_mask.logic_port, argv[index + 2]);\
        p_field->type = CTC_FIELD_KEY_PORT;\
        p_field->ext_data = &port_info;\
        p_field->ext_mask = &port_info_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("port-class");\
    if (index < action_begin) \
    {\
        port_info.type = CTC_FIELD_PORT_TYPE_PORT_CLASS;\
        CTC_CLI_GET_UINT16("value", port_info.port_class_id, argv[index + 1]);\
        CTC_CLI_GET_UINT16("mask", port_info_mask.port_class_id, argv[index + 2]);\
        p_field->type = CTC_FIELD_KEY_PORT;\
        p_field->ext_data = &port_info;\
        p_field->ext_mask = &port_info_mask;\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("customer-id");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_CUSTOMER_ID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("label-num");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_LABEL_NUM;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-label0");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_LABEL0;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-exp0");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_EXP0;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-sbit0");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_SBIT0;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-ttl0");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_TTL0;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-label1");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_LABEL1;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-exp1");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_EXP1;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-sbit1");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_SBIT1;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-ttl1");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_TTL1;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-label2");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_LABEL2;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-exp2");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_EXP2;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-sbit2");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_SBIT2;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("mpls-ttl2");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_MPLS_TTL2;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("arp-op-code");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_ARP_OP_CODE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("arp-protocol-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_ARP_PROTOCOL_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("arp-target-ip");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_ARP_TARGET_IP;\
        CTC_CLI_GET_IPV4_ADDRESS("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_IPV4_ADDRESS("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("arp-sender-ip");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_ARP_SENDER_IP;\
        CTC_CLI_GET_IPV4_ADDRESS("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_IPV4_ADDRESS("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("rarp");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_RARP;\
        CTC_CLI_GET_UINT8("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT8("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
     index = CTC_CLI_GET_ARGC_INDEX("is-y1731-oam");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_IS_Y1731_OAM;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
     index = CTC_CLI_GET_ARGC_INDEX("fcoe-dst-fcid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_FCOE_DST_FCID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
     index = CTC_CLI_GET_ARGC_INDEX("fcoe-src-fcid");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_FCOE_SRC_FCID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
     index = CTC_CLI_GET_ARGC_INDEX("egress-nickname");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_EGRESS_NICKNAME;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
     index = CTC_CLI_GET_ARGC_INDEX("ingress-nickname");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_INGRESS_NICKNAME;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-multihop");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_MULTIHOP;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-length");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_LENGTH;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-version");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_VERSION;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("is-trill-channel");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_IS_TRILL_CHANNEL;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("is-esadi");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_IS_ESADI;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-inner-vlanid");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_INNER_VLANID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-inner-vlanidvalid");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_INNER_VLANID_VALID;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-multicast");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_MULTICAST;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-ttl");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_TTL;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("trill-key-type");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_TRILL_KEY_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ether-oam-level");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_ETHER_OAM_LEVEL;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ether-oam-version");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_ETHER_OAM_VERSION;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ether-oam-op-code");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_ETHER_OAM_OP_CODE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("slow-protocol-sub-type");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_SLOW_PROTOCOL_SUB_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("slow-protocol-flags");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_SLOW_PROTOCOL_FLAGS;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("slow-protocol-code");\
    if (index < action_begin) \
    {\
        p_field->type =      CTC_FIELD_KEY_SLOW_PROTOCOL_CODE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ptp-version");\
    if (index < action_begin) \
    {\
        p_field->type =     CTC_FIELD_KEY_PTP_VERSION;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("ptp-message-type");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_PTP_MESSAGE_TYPE;\
        CTC_CLI_GET_UINT32("value", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("mask", p_field->mask, argv[index + 2]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("svlan-range");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_SVLAN_RANGE;\
        CTC_CLI_GET_UINT32("min", p_field->data, argv[index + 1])\
        CTC_CLI_GET_UINT32("max", p_field->mask, argv[index + 2])\
        index = CTC_CLI_GET_ARGC_INDEX("vrange-gid");\
        {\
            CTC_CLI_GET_UINT32("vrange-gid", vlan_mapping_group, argv[index + 1]);\
            p_field->ext_data = &vlan_mapping_group;\
        }\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("cvlan-range");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_CVLAN_RANGE;\
        CTC_CLI_GET_UINT32("min", p_field->data, argv[index + 1])\
        CTC_CLI_GET_UINT32("max", p_field->mask, argv[index + 2])\
        index = CTC_CLI_GET_ARGC_INDEX("vrange-gid");\
        {\
            CTC_CLI_GET_UINT32("vrange-gid", vlan_mapping_group, argv[index + 1]);\
            p_field->ext_data = &vlan_mapping_group;\
        }\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("xdata");\
    if (index < action_begin) \
    {\
        p_field->type =    CTC_FIELD_KEY_XDATA;\
        xdata.num = ctc_cmd_get_map_array(1,(void*) (xdata_field),argv[index+2]);\
        xdata.fields= xdata_field;\
        p_field->ext_data = &xdata;\
        arg;\
    }\
    CTC_CLI_SCL_ADD_UDF_SET(p_field,arg) \
}while(0);

/**
 *  @brief  Initialize sdk scl module CLIs, for greatbelt only
 *
 *   @param[in/out]
 *
 *    @return CTC_E_XXX
 *
 *    */
extern int32
ctc_usw_scl_cli_init(void);

extern int32
ctc_usw_scl_cli_deinit(void);

#ifdef __cplusplus
}
#endif

#endif  /* _CTC_USW_SCL_CLI_H */
